package com.kingtop.base.service.impl;

import java.util.List;
import java.util.Objects;

import javax.annotation.Resource;

import org.kingtop.mybatis.mapper.BaseServiceImpl;
import org.springframework.stereotype.Service;

import com.kingtop.base.dao.IBaseUserDao;
import com.kingtop.base.model.BaseUser;
import com.kingtop.base.service.IBaseUserService;


@Service("BaseUserService")
public class BaseUserServiceImpl extends BaseServiceImpl<BaseUser> implements IBaseUserService {

	@Resource
	private IBaseUserDao baseUserDao;

	
	@SuppressWarnings("unchecked")
	@Override
	public BaseUser getUserByUserId(Long id){
		if(id != null) {
			BaseUser baseUser = this.baseUserDao.getById(id);
			if(baseUser != null && Objects.equals(baseUser.getStatus(), 1)) {
				return baseUser;
			}
		}
		return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public BaseUser getByUsername(String userName) {
		BaseUser systemUser = this.baseUserDao.getByUsername(userName);
		return systemUser;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<BaseUser> listUserCache() {
		return this.baseUserDao.getUserCacheList();
	}

}